<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>My JSP 'index.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" type="text/css" href="css/login.css">
	<link rel="stylesheet" type="text/css" href="css/index.css">
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			$("#p_login").click(function(){
				$("#login").show("slow");
			})
			$("#title img").click(function(){
				$("#login").hide("slow");
			});
			$("#login input").focusin(function(){
	  			$(this).addClass("select");	  			
	  		}).focusout(function(){
	  			var inputObj = $(this);
	  			inputObj.removeClass("select");
	  			if(inputObj.val()=="" || inputObj.val()== null)
	  				inputObj.prev(".warning").fadeIn("50").fadeOut("slow");
	  		});
	  		$("#submit").click(function(){
	  			var obj1 = $("#username");
	  			var obj2 = $("#userpass");
	  			if(obj1.val()==null||obj2.val()==null 
	  					|| obj1.val()=="" || obj2.val()==""){
	  				alert("用户名或密码不能为空");
	  				return false;
	  			}
	  			$("#login").hide();
	  		});
		});
	</script>
  </head>
  
  <body>
	<div id='login'>
  		<div id='title'><img src="image/close.gif"/>用户登录</div>
  		<div>
  			<div style="border:0px solid black; margin:auto; margin-top:20px; width:80%; padding:5%;">
	  			<form action="../servlet/UserLogin" method="post">
	  				
	  				<span>用户名：</span><div class="warning"></div>
	  				<input type="text" name="username" id='username'><br><br>	  				
	  				
	  				<span>密&nbsp;&nbsp;码：</span><div class="warning"></div>
	  				<input type="password" name="userpass" id='userpass'><br><br>
	  				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	  				<input type="submit" value="登录" id="submit">
	  				<input type="reset" value="重置">
	  			</form>
  			</div>
  		</div>
  	</div>
  	
  	<div id="main">
  		<div id="top">
  			<div id="search">
	  		<form action="../servlet/SearchGoods" method="post">
  				<div class="left"></div>
  				<div class="middle">
		  			<input type="text" name="key" class="key">
		  		</div>
		  		<div class="right"></div>
		  		<div class="btn">
		  			<input type="submit" value="" target="_blank">
		  		</div>
		  	</form>
		  	</div>
		  	<div id="top_right">
		  	<% 
		  		String username = (String)request.getSession().getAttribute("username");
		  		if(username != "" && username != null){
		  			out.print("<a id='p_register' href=\"../servlet/UserLogout\">注销</a>");
		  			out.print("<a id='p_register' href=\"../servlet/UserCollect\">我的收藏</a>");
		  			out.print("&nbsp;<a id='p_register'>欢迎：" + username + "</a>");
		  		}else{
		  			out.print("<a id='p_register' href='register.html'>注册</a>");
		  			out.print("<a id='p_login'>登录</a>");
		  		}
		  	%>
  			</div>
  		</div>
  		<div id="ad">
  			广告区
  		</div>
  		<div id="share">
  			分享
  		</div>
  		<div id="footer">
  			copyright
  		</div>
  	</div>
  	
  </body>
</html>
